/*
 * @Author: your name
 * @Date: 2020-09-13 08:42:53
 * @LastEditTime: 2020-10-04 16:35:09
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \woniutaofang\lib\pages\house\house_page.dart
 */
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:woniutaofang/pages/home/widgets/search_widget.dart';

class HousePage extends StatefulWidget {
  const HousePage({Key key}) : super(key: key);

  @override
  _HousePageState createState() => _HousePageState();
}

class _HousePageState extends State<HousePage>
    with AutomaticKeepAliveClientMixin {
  @override
  bool get wantKeepAlive => true;

  List list = ['', '', ''];
  EasyRefreshController _controller = EasyRefreshController();
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    print('新房初始化了');
    super.build(context);
    _controller.finishLoad(noMore: true);
    return Scaffold(
      appBar: AppBar(
        title: Text('新房'),
        automaticallyImplyLeading: false,
        elevation: 4.0,
        // shape:ShapeBorder.lerp(a, b, t),
        backgroundColor: Colors.red,
      ),
      body: EasyRefresh(
        controller: _controller,
        onLoad: () async {
          await Future.delayed(
            Duration(seconds: 2),
            () {
              if (mounted) {
                setState(
                  () {
                    list..add({})..add({})..add({});
                  },
                );
                _controller.finishLoad(noMore: list.length >= 10);
              }
            },
          );
        },
        onRefresh: () async {
          await Future.delayed(
            Duration(seconds: 2),
            () {
              if (mounted) {
                setState(
                  () {
                    list = ['', '', ''];
                  },
                );
                _controller.finishLoad(noMore: false, success: true);
              }
            },
          );
        },
        child: Column(
          children: <Widget>[SearchWidget()],
        ),
      ),
    );
  }
}
